export function cleanEcharts(data) {
    return {
        tooltip: {
            trigger: 'item'
        },
        legend: {

        },
        grid: {
            top: '20',
            left: '5',
            bottom: '5',
            right: '5'
        },
        series: [
            {
                type: 'pie',
                radius: ['0%', '80%'],
                labelLine: {
                    show: false
                },
                left: '5',
                top: '20',
                bottom: '5',
                right: '5',
                label: {
                    show: false,
                    position: 'center'
                },
                data: [
                    { value: data[0], name: '正常清扫' },
                    { value: data[1], name: '故障清扫' },
                ],
                color: ['#048fff', '#979797'],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    }
}

export function statusEcharts(yData) {
    return {
        tooltip: {
            trigger: 'item'
        },
        legend: {
            // top: '2%',
            left: 'center'
        },
        series: [
            {
                type: 'pie',
                radius: ['50%', '70%'],
                avoidLabelOverlap: false,
                label: {
                    show: false,
                    position: 'center'
                },
                emphasis: {
                    label: {
                        show: true,
                        fontSize: 20,
                        fontWeight: 'bold'
                    }
                },
                labelLine: {
                    show: false
                },
                data: [
                    { value: yData[0], name: '提示' },
                    { value: yData[1], name: '告警' },
                    { value: yData[2], name: '故障' },
                ],
                color: ['#048fff', '#FFC43E', '#FF6650']
            }
        ]
    }
}

// 出仓
export function robotOutEcharts(ratioNum) {
    return {
        tooltip: {
            trigger: 'item',
            formatter: (value) => {
                // console.log(value)
                return `出仓率${value.data.value}%`
            }
        },
        grid: {
            top: '20',
            left: '5',
            bottom: '5',
            right: '5'
        },

        series: [
            {
                type: 'gauge',
                center: ['50%', '50%'],
                radius: '100%',
                axisLine: {
                    lineStyle: {
                        width: 25,
                        color: [
                            [0.25, '#FF5D49'],
                            [0.5, '#F6C651'],
                            [0.75, '#2DBD5E'],
                            [1, '#279E52']
                        ]
                    }
                },
                pointer: {
                    itemStyle: {
                        color: 'auto'
                    }
                },
                axisTick: {
                    distance: -30,
                    length: 10,
                    lineStyle: {
                        color: '#fff',
                        width: 2
                    }
                },
                splitLine: {
                    distance: -30,
                    length: 30,
                    lineStyle: {
                        color: '#fff',
                        width: 2
                    }
                },
                axisLabel: {
                    color: 'inherit',
                    distance: 40,
                    fontSize: 10
                },
                detail: {
                    valueAnimation: true,
                    formatter: '{value} %',
                    color: 'inherit',
                    fontSize: 13
                },
                data: [
                    {
                        value: ratioNum
                    }
                ]
            }
        ]
    };
}

// 故障数
export function faultEcharts(xData, yData) {

    return {
        tooltip: {
            trigger: 'item',

        },
        xAxis: {
            type: 'category',
            data: xData
        },
        grid: {
            top: '20',
            left: '40',
            bottom: '35',
            right: '25'
        },
        yAxis: {
            type: 'value'
        },
        series: [
            {
                data: yData,
                type: 'line'
            }
        ]
    }
}


// 故障数
export function ratioEcharts(xData, yData) {

    return {
        tooltip: {
            trigger: 'item',
            valueFormatter: (value) => {
                return `出仓率 ${value * 100}%`
            }
        },
        xAxis: {
            type: 'category',
            data: xData
        },
        grid: {
            top: '20',
            left: '40',
            bottom: '35',
            right: '25'
        },
        yAxis: {
            type: 'value'
        },
        series: [
            {
                data: yData,
                type: 'line',
                lineStyle: {
                    color: '#FFC43E'
                },
                itemStyle: {
                    color: '#FFC43E', // 设置圆点的颜色为红色
                },
            },
        ]
    }
}